package org.lakesidecdc.outreach.client;


import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DockPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

public class ProjectDetail extends Composite {
	
	private VerticalPanel panel = new VerticalPanel();
	private VerticalPanel headerPanel = new VerticalPanel();
	private HTML description = new HTML();
	private HTML volunteerHours = new HTML();
	private HTML staffHours = new HTML();
	private ScrollPanel scroller = new ScrollPanel(description);
	private VerticalPanel eventListContainer = new VerticalPanel();
	private Project project;
	
	public ProjectDetail() {
		description.setWordWrap(true);
		
		headerPanel.add(volunteerHours);
		headerPanel.add(staffHours);
		//headerPanel.setWidth("100%");
		
		DockPanel innerPanel = new DockPanel();
		innerPanel.add(headerPanel, DockPanel.NORTH);
		innerPanel.add(scroller, DockPanel.CENTER);
		innerPanel.add(eventListContainer, DockPanel.WEST);
		innerPanel.setWidth("600px");
		
		panel.add(innerPanel);
		innerPanel.setSize("50%", "50%");
	    scroller.setSize("50%", "50%");
	    //innerPanel.setStyleName(DockPanel.CENTER, ".centerPanel");
	    initWidget(panel);
	    
	    setStyleName("project-Detail");
	    headerPanel.setStyleName("project-DetailHeader");
	    innerPanel.setStyleName("project-DetailInner");
	    volunteerHours.setStyleName("project-DetailVolunteer");
	    staffHours.setStyleName("project-DetailStaff");
	    description.setStyleName("project-Description");
	    eventListContainer.setStyleName("eventContainer");
	    scroller.setStyleName("scroller");
	}
	
	public void adjustSize(int windowWidth, int windowHeight) {
		int scrollWidth = windowWidth - scroller.getAbsoluteLeft() - 9;
		if (scrollWidth < 1) {
			scrollWidth = 1;
		}

		int scrollHeight = windowHeight - scroller.getAbsoluteTop() - 9;
		if (scrollHeight < 1) {
			scrollHeight = 1;
		}

		scroller.setPixelSize(scrollWidth, scrollHeight);
	}

	public void setProject(Project project) {
		this.project = project;
		volunteerHours.setHTML("Volunteer Hours: <b>" + /*project.getVolunteerHours()*/ "0" + "</b>");
		staffHours.setHTML("Staff Hours: <b>" + /*project.getStaffHours()*/ "0" + "</b>");
		description.setHTML(project.getDescription());
		//eventListContainer.add(project.getEventList());
	}
	
//	public EventList getEventList() {
//		return project.getEventList();
//	}
}
